import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

public class Test4 {
    public static void main(String[] args) {
        List<Student> Students = new ArrayList<>();
        Student s1 = new Student("蜘蛛精", 26, 172.5);
        Student s2 = new Student("蜘蛛精",26, 172.5);
        Student s3 = new Student("紫霞",23, 167.6);
        Student s4 = new Student("白晶晶",25, 169.0);
        Student s5 = new Student("牛魔王",35, 183.3);
        Student s6 = new Student("牛夫人",34, 168.5);
        Collections.addAll(Students, s1, s2, s3, s4, s5, s6);

        // 需求1:请计算出身高超过168的学生有几人。
        long count = Students.stream().filter(s -> s.getHeight() > 168).count();
        System.out.println(count);
        System.out.println("------------------------");

        // 需求2:请找出身高最高的学生对象，并输出。
        Student student = Students.stream().max((o1, o2) -> Double.compare(o1.getHeight(), o2.getHeight())).get();
        System.out.println(student);
        System.out.println("------------------------");

        // 需求3:请找出身高最矮的学生对象，并输出。
        Student student1 = Students.stream().min((o1, o2) -> Double.compare(o1.getHeight(), o2.getHeight())).get();
        System.out.println(student1);
        System.out.println("------------------------");

        //需求4:请找出身高超过170的学生对象，并放到一个新集合中去返回。
        Students.stream().filter(s -> s.getHeight() > 170).distinct().collect(Collectors.toList()).forEach(System.out::println);
        System.out.println("------------------------");

        //需求5:请找出身高超过170的学生对象，并把学生对象的名字和身高，存入到一个Map集合返回。
        Students.stream().filter(z ->z.getHeight() > 170).distinct().collect(Collectors.toMap(Student::getName, Student::getHeight)).
                forEach((k,v)-> System.out.println(k+"---"+v));

















    }
}
